<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>设置</title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
		<style>
			body {
			}
			.cellHeight {
				height: 38px;
				position: relative;
			}
			.cell_img {
				position: absolute;
				width: 20px;
				height: 20px;
				bottom: 12px;
			}
			.titleSet {
				padding-left: 30px;
				font-size: 14px;
			}
			.bottom0 {
				position: fixed;
				bottom: 0;
				left: 0;
				width: 100%;
				height: 49px;
				border-top: solid 1px #ededed;
				line-height: 49px;
				background-color: #ff9900;
			}
			.cacheSize {
				position: absolute;
				bottom: 12px;
				width: 70px;
				height: 20px;
				font-size: 14px;
				text-align: right;
				/* right: 35px; */
				right: 15px;
			}
		</style>
	</head>
	<body>
		<div class="base_style_color base_title_Immerse" id='BarAppearance' ></div>
		<div class="base_navigation_bar base_style_color base_navigation_item_bar base_title_position" >
			<a class="base_left_item" href="#" onclick="backClick()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
			<span id="newsTitle">设置</span>
			<a class="base_right_item nav-item" ></a>
		</div>
		<ul class="mui-table-view" style="    margin-top: 66px;">
			<li  id="my_cache" class="mui-table-view-cell mui-media">
				<a  href="javascript:;"> <img class="cell_img" src="../../icon/icon_qingchu.png">
				<div class="mui-media-body base_dark_grey titleSet">
					清除缓存
				</div> </a>
				<span id="cacheValue" class="cacheSize" style="color:#b0b0b0;">0 B</span>
			</li>
			<li  id="account_security" class="mui-table-view-cell mui-media">
				<a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="../../icon/icon_zuji.png">
				<div class="mui-media-body base_dark_grey titleSet">
					账号安全
				</div> </a>
			</li>
			<li  id="suggestBack" class="mui-table-view-cell mui-media">
				<a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="../../icon/icon_fankui.png">
				<div class="mui-media-body base_dark_grey titleSet">
					反馈意见
				</div> </a>
			</li>
			<li id="my_about" class="mui-table-view-cell mui-media">
				<a class='mui-navigate-right' href="javascript:;"> <img class="cell_img" src="../../icon/icon_guanyu.png">
				<div class="mui-media-body base_dark_grey titleSet">
					关于我们
				</div> </a>
			</li>
		</ul>
		<div class="seize-a-seat-div"></div>
		<div class=" bottom0" id="offline_btn" onclick="tuichu()">
			<div  class=" base_title_font " style="text-align: center;color: #FFFFFF">
				退出账号
			</div>
		</div>
		<div id="cleanCache" class="weui_dialog_confirm" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title">确定清除缓存？</strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
					<a onclick="cancleCache()" href="#" class="weui_btn_dialog default"  style="color:#18b4ed">取消</a>
					<a onclick="confirmCache()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript">
		apiready = function() {
		    initClick();
			setupCache();
		};
		function initClick(){
			//缓存
			$('#my_cache').click(function() {
				$('#cleanCache').show();
			});
			//账号安全
			$('#account_security').click(function() {
				api.openWin({useWKWebView:true,
					name : 'AccountSecurity',
					url : 'AccountSecurity.html',
					animation : {
						type : "none", //动画类型（详见动画类型常量）
						subType : "from_right", //动画子类型（详见动画子类型常量）
						duration : 300 //动画过渡时间，默认300毫秒
					}
				});
			});
			//关于我们
			$('#my_about').click(function() {
				api.openWin({useWKWebView:true,
					name : 'about',
					url : 'about.html',
					animation : {
						type : "none", //动画类型（详见动画类型常量）
						subType : "from_right", //动画子类型（详见动画子类型常量）
						duration : 300 //动画过渡时间，默认300毫秒
					}
				});
			});
			$('#suggestBack').click(function() {//反馈意见
				api.openWin({useWKWebView:true,
					name : 'suggestBack',
					url : 'suggestBack.html',
					animation : {
						type : "none", //动画类型（详见动画类型常量）
						subType : "from_right", //动画子类型（详见动画子类型常量）
						duration : 300 //动画过渡时间，默认300毫秒
					},
					slidBackEnabled : false,
				});
			});
		}

		function setupCache() {
			//获取缓存
			api.getCacheSize(function(ret, err) {
				if (ret) {
					var cacheSize = bytesToSize(parseInt(ret.size));
					// alert(JSON.stringify(cacheSize));
					$("#cacheValue").html(cacheSize);
				}
			});
		}

		// 字节转换
		function bytesToSize(bytes) {
			//alert(bytes);
			if ((bytes - 557424) <= 0)
				return '0 B';
			// if(bytes == 0) return '0 KB';
			var k = 1000;
			var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
			var i = Math.floor(Math.log(bytes) / Math.log(k));
			return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
		}

		function tuichu() {
			cleanConfirm();
		}

		//取消
		function cleanCancel() {
			$('#offlineAlert').hide();
		}

		//确定
		function cleanConfirm() {
			//      $('#offlineAlert').hide();
			api.toast({
				msg : '退出登录成功',
				duration : 1000,
				location : 'bottom'
			});
//			unbindAccount();
			$api.setStorage('cfnetppLoginStatus', 0);
			$api.setStorage('cfnetppusericon', "");
			$api.setStorage('cfnetUserName', "");
			$api.setStorage('cfnetppjxidname', "");
			$api.setStorage('stdydata', "");
			//清空学习集团
			$api.setStorage('practicedata', "");
			//清空实习集团
			$api.setStorage('cfnetpppassword', "");
			$api.setStorage('cfnetppuid', "");
			$api.setStorage('cfnetppjxid', "");
			$api.setStorage('cfnetSelectType', "");
			$api.setStorage('cfnetppusername', "");
            api.closeWin({
				name : 'index',
				animation : {
					type : "none", //动画类型（详见动画类型常量）
					subType : "from_right", //动画子类型（详见动画子类型常量）
					duration : 100
				},
			});
			api.openWin({useWKWebView:true,
				name : 'login',
				url : '../../login.html',
				slidBackEnabled : false,
				animation : {
					type : "none", //动画类型（详见动画类型常量）
					subType : "from_right", //动画子类型（详见动画子类型常量）
					duration : 100
				},
			});
			
		}

		// 取消清除
		function cancleCache() {
			$("#cleanCache").hide();
		}

		// 确定清除
		function confirmCache() {
			$("#cleanCache").hide();
			api.clearCache(function(ret, err) {
				if (ret) {
					ShowToast("清除缓存成功！");
					$("#cacheValue").html("0 B");
				}
			});
		}
	</script>
</html>